package com.ccrego.haiyi.demo.baseui;

import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ccrego.haiyi.R;
import com.pachong.android.baseuicomponent.CompState;
import com.pachong.android.baseuicomponent.activity.BaseActivity;

import butterknife.ButterKnife;

public class BaseUIDemoActivity extends BaseActivity {

    Handler handler = new Handler();

    int count = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.bind(this);

        setTitle("BaseUIDemoActivity");
        send();

    }

    void send() {
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                switch (count) {
                    case 0:
                        setState(CompState.DATA);
                        count = (count + 1) % 5;
                        send();
                        break;

                    case 1:
                        setState(CompState.EMPTY);
                        count = (count + 1) % 5;
                        send();
                        break;

                    case 2:
                        setState(CompState.EMPTY_REFRESHING);
                        count = (count + 1) % 5;
                        send();
                        break;
                    case 3:
                        setState(CompState.EMPTY_INVALID_NEWWORK);
                        count = (count + 1) % 5;
                        send();
                        break;

                    case 4:
                        setState(CompState.EMPTY_ERROR);
                        count = (count + 1) % 5;
                        send();
                        break;
                }

            }
        }, 1000);
    }

    @Override
    public View createDataView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.activity_base_ui_demo, null);
    }

   /* @Override
    public View createEmptyErrorView(LayoutInflater inflater) {
        return View.inflate(this, com.pachong.android.baseuicomponent.R.layout.default_empty_error, null);
    }*/
}